package com.example.demo;


import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.sql.DataSource;

@ComponentScan("com.example")
//@ComponentScan({"com.example","com.test"})
@SpringBootApplication
@MapperScan("com.example.demo.mapper")
@EnableScheduling
public class DemoApplication {

    private  static  final Logger LOG= (Logger) LoggerFactory.getLogger(DemoApplication.class);

    @Bean
    public static DataSource dataSource() {
        HikariConfig config = new HikariConfig();
        config.setDriverClassName("com.mysql.cj.jdbc.Driver");
        config.setJdbcUrl("jdbc:mysql://123.56.165.41:3306/workdev?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai");
        config.setUsername("root");
        config.setPassword("whn.1314.+");

        return new HikariDataSource(config);
    }
    public static void main(String[] args) {
        SpringApplication app=new SpringApplication(DemoApplication.class);
       // dataSource();
        Environment env=app.run(args).getEnvironment();
      //  Environment env= app.run(args).getEnvironment();

        LOG.info("启动成功！！");
        LOG.info("地址 :\thttp://127.0.0.1:{}",env.getProperty("server.port"));
        LOG.info("地址 :\thttp://127.0.0.1:{}",env.getProperty("server.port"));

    }



}
